package com.jack.concurrenthashmap;

import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;

/**
 * Created by zhang_j on 2019/10/22
 */
public class PutTest {
    public static void main(String[] args) {
        ConcurrentMap<String,String> map1 = new ConcurrentHashMap<>();
        map1.put("1","1");
        map1.put("1","2");
        map1.get("1");
        //2
        System.out.println(map1.get("1"));

        ConcurrentMap<String,String> map2 = new ConcurrentHashMap<>();
        map2.putIfAbsent("1","1");
        map2.putIfAbsent("1","2");
        //1
        System.out.println(map2.get("1"));
    }
}
